﻿using System;
using System.Configuration;
using AppCommon;
using Controller;

public partial class Album_detail : System.Web.UI.Page
{
    public static string urlWebsite = ConfigurationManager.ConnectionStrings["URLWebsite"].ToString();
    public static string linkTour;
    public static string _meta_description;
    public static string _meta_title;
    public static string _meta_image;
    public static string _meta_url;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var id = Request.QueryString["Id"];
            if (id != null)
            {
                BindData(id);
                BindPhotos(id);
            }
        }
    }

    public void BindData(string id)
    {
        var controller = new VYC21Controller();
        var list = controller.GetById(id);
        if (list.Count > 0)
        {
            _meta_title = list[0].Ten;
            _meta_description = list[0].TomTat;
            _meta_image = urlWebsite + "/Upload/AlbumAnh/" + list[0].AnhDaiDien;
            linkTour = _meta_url = urlWebsite + "album-anh/" + list[0].Id;

            litTieude.Text = list[0].Ten;
            litTitleTop.Text = list[0].Ten;
            litNgaycapnhat.Text = list[0].NgayCapNhat.ToString("dd/MM/yyyy");

            litTomtat.Text = list[0].TomTat;            
        }
    }

    public void BindPhotos(string id)
    {
        var controller = new VYC22Controller();
        var model = controller.GetLimitAlbumForModule(1, id);
        if (model.Count > 0)
        {
            repeaterPhoto.DataSource = model;
            repeaterPhoto.DataBind();

            litNoidung.Text = Server.HtmlDecode(model[0].NoiDung);
        }
    }
}